/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author DangThanh
 */
@Entity
@Table(name = "Examination", catalog = "MailServerDB", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Examination.findAll", query = "SELECT e FROM Examination e"),
    @NamedQuery(name = "Examination.findByExamId", query = "SELECT e FROM Examination e WHERE e.examId = :examId"),
    @NamedQuery(name = "Examination.findByStudentName", query = "SELECT e FROM Examination e WHERE e.studentName = :studentName"),
    @NamedQuery(name = "Examination.findByExamDate", query = "SELECT e FROM Examination e WHERE e.examDate = :examDate"),
    @NamedQuery(name = "Examination.findByMark", query = "SELECT e FROM Examination e WHERE e.mark = :mark"),
    @NamedQuery(name = "Examination.findByResult", query = "SELECT e FROM Examination e WHERE e.result = :result")})
public class Examination implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "exam_id", nullable = false)
    private Integer examId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "student_name", nullable = false, length = 255)
    private String studentName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "exam_date", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date examDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "mark", nullable = false)
    private double mark;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 6)
    @Column(name = "result", nullable = false, length = 6)
    private String result;
    @JoinColumn(name = "course_id", referencedColumnName = "course_id", nullable = false)
    @ManyToOne(optional = false)
    private Courses courseId;

    public Examination() {
    }

    public Examination(Integer examId) {
        this.examId = examId;
    }

    public Examination(Integer examId, String studentName, Date examDate, double mark, String result) {
        this.examId = examId;
        this.studentName = studentName;
        this.examDate = examDate;
        this.mark = mark;
        this.result = result;
    }

    public Integer getExamId() {
        return examId;
    }

    public void setExamId(Integer examId) {
        this.examId = examId;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public Date getExamDate() {
        return examDate;
    }

    public void setExamDate(Date examDate) {
        this.examDate = examDate;
    }

    public double getMark() {
        return mark;
    }

    public void setMark(double mark) {
        this.mark = mark;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public Courses getCourseId() {
        return courseId;
    }

    public void setCourseId(Courses courseId) {
        this.courseId = courseId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (examId != null ? examId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Examination)) {
            return false;
        }
        Examination other = (Examination) object;
        if ((this.examId == null && other.examId != null) || (this.examId != null && !this.examId.equals(other.examId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "app.entity.Examination[ examId=" + examId + " ]";
    }
}
